import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const Music = () => import('../pages/Music.vue')
const News = () => import('../pages/News.vue')

const router = new VueRouter({
  mode:'history',
  routes:[
    {
      path:'/music',
      component:Music
    },
    {
      path:'/news/:id',
      component:News,
      beforeEnter(to,from,next){
        console.log('beforeEnter,路由独享守卫');
        next()
      }
    }
  ]
})
router.beforeEach((to,from,next) => {
  console.log('beforeEach,全局前置守卫');
  next()
})
router.beforeResolve((to,from,next) => {
  console.log('beforeResolve,全局解析守卫');
  next()
})
router.afterEach(() => {
  console.log('afterEach,全局后置钩子');
})
export default router